package com.example.javabasic.bean.demo1;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/** 测试bean
 * @description
 * @Author Lin FuYuan
 * @date 2020/12/21
 */
public class TestBean {
    public static void main(String[] args) {
        //注册bean容器
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        Object appConfig = context.getBean("user");
        System.out.println(appConfig);

    }
//
//    //spring 三级缓存方法
//    @Nullable
//    protected Object getSingleton(String beanName, boolean allowEarlyReference) {
//        Object singletonObject = this.singletonObjects.get(beanName);
//        //是否在创建过程
//        if (singletonObject == null && isSingletonCurrentlyInCreation(beanName)) {
//            synchronized (this.singletonObjects) {
//                singletonObject = this.earlySingletonObjects.get(beanName);
//                if (singletonObject == null && allowEarlyReference) {
//                    ObjectFactory<?> singletonFactory = this.singletonFactories.get(beanName);
//                    if (singletonFactory != null) {
//                        singletonObject = singletonFactory.getObject();
//                        this.earlySingletonObjects.put(beanName, singletonObject);
//                        this.singletonFactories.remove(beanName);
//                    }
//                }
//            }
//        }
//        return singletonObject;
//    }
}
